//
//  WHYHeadLineCell.m
//  News163
//
//  Created by 王洪运 on 16/1/3.
//  Copyright © 2016年 王洪运. All rights reserved.
//

#import "WHYHeadLineCell.h"
#import "WHYHeadLine.h"
#import "UIImageView+WebCache.h"

@interface WHYHeadLineCell ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet UILabel *digestLabel;

@property (weak, nonatomic) IBOutlet UILabel *replyLabel;

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;

@property (weak, nonatomic) IBOutlet UIImageView *secondImageView;

@property (weak, nonatomic) IBOutlet UIImageView *thirdImageView;


@end

@implementation WHYHeadLineCell

+(CGFloat)headLineCellHeightWithHeadLine:(WHYHeadLine *)headLine {
    
    if (headLine.imgextra.count == 2) {
        return 120;
    }
    
    if (headLine.imgType) {
        return 180;
    }
    
    return 80;
    
}

+(NSString *)headLineCellIdentifierWithHeadLine:(WHYHeadLine *)headLine; {
    
    if (headLine.imgextra.count == 2) {
        return @"imagesCell";
    }
    
    if (headLine.imgType) {
        return @"bigImageCell";
    }
    
    return @"newsCell";
}

-(void)setHeadLine:(WHYHeadLine *)headLine {
    _headLine = headLine;
    
    self.titleLabel.text = headLine.title;
    self.digestLabel.text = headLine.digest;
    self.replyLabel.text = [NSString stringWithFormat:@"%d跟帖",headLine.replyCount];
    
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:headLine.imgsrc] placeholderImage:[UIImage imageNamed:@"loading"]];
     
    if (headLine.imgextra.count == 2) {
        [self.secondImageView sd_setImageWithURL:[NSURL URLWithString:headLine.imgextra.firstObject[@"imgsrc"]] placeholderImage:[UIImage imageNamed:@"loading"]];
        [self.thirdImageView sd_setImageWithURL:[NSURL URLWithString:headLine.imgextra.lastObject[@"imgsrc"]] placeholderImage:[UIImage imageNamed:@"loading"]];
    }
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
